package org.example.entity;

import org.example.util.DateUtil;

import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Serializable;

/**
 * @author TonySong
 * @date 2025/7/28 0028
 * @time 16:36
 */
public class FreeTicket extends Ticket implements Serializable {
    private String customerName;

    @Override
    public int calc() {
        return 0;
    }

    public String getCustomerName() {
        return customerName;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }

    public FreeTicket(Movie movie) {
        super(movie);
    }

    @Override
    public String toString() {
        return  super.toString()+"FreeTicket{" +
                "customerName='" + customerName + '\'' +
                '}';
    }

    @Override
    public void print() throws IOException {
        String fname= DateUtil.createTime();
        PrintWriter writer =new PrintWriter(new FileWriter("赠票"+fname+".txt"));
        writer.println("========================夜不归宿电影院欢迎您====================================\r\n");
        writer.println("电影名称："+this.getMovie().getName()+"时间："+DateUtil.showDate(this.getMovie().getPlayTime())+"\r\n");
        writer.print("座位号："+this.getSeat()+"\r\n");
        writer.print("票价："+this.calc()+"元\r\n");
        writer.print("赠票,客户姓名："+this.customerName+"\r\n");
        writer.print("====================感谢您的光临====================\r\n");
        writer.close();
    }
}
